package com.rivulet.doj_backend.controller.admin;


import com.rivulet.doj_backend.pojo.request.business.LoginRequest;
import com.rivulet.doj_backend.service.EmailService;
import com.rivulet.doj_backend.service.UserService;
import com.rivulet.doj_backend.tools.ResultFul;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;


@RestController
@RequestMapping(value = "/api/doj/admin")
public class UserController {

    @Autowired
    UserService userService;

    @Autowired
    EmailService emailService;

    @RequestMapping(value = ("/login"), method = RequestMethod.POST)
    public ResultFul Login(@RequestBody LoginRequest loginRequest) {
        return userService.login(loginRequest);
    }
//
//    @RequestMapping(value = ("/register"), method = RequestMethod.POST)
//    public ResultFul Register(@RequestBody HashMap<String, String> map) {
//        String code = map.get("code");
//        User user = new User(map.get("username"), map.get("password"));
//        ResultFul result = new ResultFul<Object>(userService.userRegister(user, code), null);
//        return result;
//    }
//
//    @RequestMapping(value = ("/register/getEmailCode"), method = RequestMethod.POST)
//    public ResultFul emailCheck(@RequestBody HashMap<String, String> map) {
//        String username = map.get("username");
//        System.out.println(username + "------getEmail");
//        emailService.sendEmail(new Email(username));
//        ResultFul result = new ResultFul<Object>(100, null);
//        return result;
//    }
//
//
//    @RequestMapping(value = ("/user/add"), method = RequestMethod.POST)
//    public ResultFul add (String username, String password, Integer Identity){
//        User user = new User(username, password, Identity);
//        System.out.println(username);
//        ResultFul result = new ResultFul<Object>(userService.userAdd(user), null);
//        return result;
//    }
//    @RequestMapping(value = ("/user/{user_id}/delete"), method = RequestMethod.POST)
//    public ResultFul delete(@PathVariable Integer user_id){
//        ResultFul result = new ResultFul<Object>(userService.userDelete(user_id), null);
//        return result;
//    }
//
//    @RequestMapping(value = ("/user/{user_id}/change"), method = RequestMethod.POST)
//    public ResultFul change(@PathVariable Integer user_id, String username, String password, Integer Identity){
//        User user = new User(user_id, username, password, Identity);
//        ResultFul result = new ResultFul<Object>(userService.userChange(user), null);
//        return result;
//    }
//
//    @RequestMapping(value = ("/user/{user_id}/select"), method = RequestMethod.POST)
//    public ResultFul select(@PathVariable Integer user_id){
//        ResultFul result = new ResultFul<Object>(userService.userSeek(user_id), userService.userSelect(user_id));
//        return result;
//    }
}
